<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">填写日记</div>
      </div>
      <div class="x-pro-list">
        <div class="x-pro-row">
          <div class="x-pro-label">记录时间:</div>
          <div class="x-pro-input">
            {{cardsmonth}}
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">职务:</div>
          <div class="x-pro-input">
            {{thjobs}}
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">是否同意分享:</div>
          <div class="x-pro-input">
            <el-switch v-model="isshare" active-color="#13ce66" inactive-color="#cccccc"></el-switch>
          </div>
        </div>
      </div>
      <div class="x-pro-list">
        <div class="x-pro-row">
          <div class="x-pro-label">标题:</div>
          <div class="x-pro-input">
            <el-input v-model="title" placeholder="请输入内容"></el-input>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">内容:</div>
          <div class="x-pro-input">
            <el-input type="textarea" :rows="4" placeholder="请输入内容" v-model="content"></el-input>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-gobtn" @click="isok">提交</div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    var tjobs = $api.getStorage('jobsth');
    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          thid:'',
          input1:'',
          input2:'',
          input3:'',
          isshare:false,
          title:'',
          content:'',
          cardsmonth:'',
          thjobs:'',
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.thjobs = tjobs;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate();
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year + month + day;
        that.cardsmonth = toMonth;
      },
      methods: {
        isok:function(){
          let that=this;
          console.log(that.isshare);
          if(that.isshare){
            that.isshare = 1;
          }else{
            that.isshare = 0;
          }
          api.ajax({
            url:baseurl+'api/note/comAdd',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                title:that.title,
                content:that.content,
                is_share:that.isshare
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.sendEvent({
                    name: 'addnoteok',
                    extra: {

                    }
                });
                api.alert({
                    title: '提交成功',
                    msg: '',
                }, function(ret, err) {
                  api.closeWin();
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
